﻿// 初始化 函数
function init() {
    var canvas = document.getElementById("renderCanvas");
	var engine = new BABYLON.Engine(canvas, true);
	
/*	// 获取资源
	BABYLON.SceneLoader.Load("Assets/", "1.babylon", engine, function (scene){
		// activeCamera 相机  
		scene.activeCamera.attachControl(canvas);
		
		engine.runRenderLoop(function (){
			scene.render();
		});
	});
*/
	BABYLON.SceneLoader.Load("Assets/", "1.babylon", engine, function (scene){		
		//alert(scene.lights);
		//alert(scene.cameras);
		//alert(scene.cameras[1]);
		//alert(scene.meshes);
		//alert(scene.materials);
		
		
		console.log(scene);
		
		// //获取场景中所有物体 数组
		// console.log(scene.meshes);
		// console.log(scene.meshes[0]);
		// console.log(scene.meshes[1]);
		// console.log(scene.meshes[2]);
		// console.log(scene.meshes[0].checkCollisions);
		
		// scene.meshes[0].checkCollisions=true;
		// console.log(scene.meshes[0].checkCollisions);
		
		// console.log(scene.meshes[2].edgesColor);
		// scene.meshes[2].edgesColor.r=0;
		// scene.meshes[2].edgesColor.g=0;
		// scene.meshes[2].edgesColor.b=0;
		// scene.meshes[2].edgesColor.a=0;
		// console.log(scene.meshes[2].edgesColor);
		
		// console.log(scene.meshes[2].absolutePosition);
		// scene.meshes[2].absolutePosition.x = 5 
		
		// //获取 相机相关参数
		// console.log(scene.cameras);
		// console.log(scene.cameras[0]);
		// console.log(scene.cameras[0].checkCollisions);
		
		// //设置相机 碰撞
		// scene.cameras[0].checkCollisions=true;
		// console.log(scene.cameras[0].checkCollisions);
		
		// // 改变场景的背景色
		scene.clearColor = new BABYLON.Color4(0, 1, 1, 1);
		
		
		// activeCamera 相机  
		scene.activeCamera.attachControl(canvas);

		
    // create a built-in "sphere" shape; its constructor takes 4 params: name, subdivisions, radius, scene
    var sphere = BABYLON.Mesh.CreateSphere('sphere1', 16, 2, scene);
    
    // move the sphere upward 1/2 of its height
    sphere.position.y = 2;
	
	
	 var picBord = BABYLON.Mesh.CreatePlane('aa', 2, scene);  
	 picBord.position.x = 5;  //位置
	 picBord.position.y = 1;  //位置
	 picBord.position.z = 2;  //位置
	 picBord.rotation.x = Math.PI / 6; //旋转(z轴)
	 picBord.rotation.y = Math.PI / -6; //旋转(z轴)
	 
	// 贴图
	imgUrl = 'http://orb9dbudl.bkt.clouddn.com/1%E6%95%99%E5%B8%88%E7%AE%80%E5%8E%86.jpg';
	var bumpMaterial = new BABYLON.StandardMaterial('aa', scene);
	//bumpMaterial.diffuseColor = new BABYLON.Color3(0, 0, 1);//Blue
	bumpMaterial.diffuseTexture = new BABYLON.Texture(imgUrl, scene);
	picBord.material = bumpMaterial; 
		
		
		
		engine.runRenderLoop(function (){
			scene.render();
		});
	});
	

	

}







































































































































